package org.cyhz.standardize.dao;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.cyhz.domain.AutoInfoVO;

public interface CarInfoDao {

	/**
	 * TODO:UNDONE,2013-11-20。 查找时间范围内， 未标准化过的(sbrand is null and sseries is
	 * null)， 能直接标准化的(在品牌和车系的修订中出现)， 同品牌内(按品牌一个个查)， 不重复的(需要详细输出)非标准品牌和非标准车系
	 * 
	 * <pre>
	 * select distinct brand,series 
	 * from autoinfosource 
	 * where 1 = 1 
	 * and brand in {brands} 
	 * and series in {series} 
	 * and releasetime between {startDate} and {endDate}
	 * and sbrand is null
	 * and sseries is null
	 * </pre>
	 * 
	 * @return collection of {@link AutoInfoVO} , non selected attribute set
	 *         None value
	 * @throws SQLException
	 */
	List<AutoInfoVO> getSimpleNbSbByNbNsAndReleaseTime(
			@Param("brands") List<String> brands,
			@Param("series") List<String> series,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate)
			throws SQLException;

	/**
	 * TODO:UNDONE,2013-11-20。更新操作
	 * 
	 * <pre>
	 * update autoinfosource set sbrand = {sbrand} , sseries = {sseries}
	 * where 1 = 1 
	 * and sbrand is null 
	 * and sseries is null 
	 * and brand = {brand}
	 * and series = {series}
	 * and releasetime between {startDate} and {endDate}
	 * </pre>
	 * 
	 * @param sb
	 * @param ss
	 * @param nb
	 * @param ns
	 * @param startDate
	 * @param endDate
	 * @return effect rows
	 * @throws SQLException
	 */
	int updateSbSsByNbNs(@Param("sb") String sb, @Param("ss") String ss,
			@Param("nb") String nb, @Param("ns") String ns,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate)
			throws SQLException;

	/**
	 * TODO:UNDONE,2013-11-20。
	 * 
	 * <pre>
	 * 查找时间范围内，
	 * 未标准化过的(sbrand is null and sseries is null)，
	 * 不重复的(需要详细输出)非标准品牌、非标准车系、标题、车型名称
	 * </pre>
	 * 
	 * <pre>
	 * select distinct brand,series,title,autoname
	 * from autoinfosource 
	 * where 1 = 1 
	 * and releasetime between {startDate} and {endDate}
	 * and sbrand is null
	 * and sseries is null
	 * </pre>
	 * 
	 * @return collection of {@link AutoInfoVO}
	 * @throws SQLException
	 */
	List<AutoInfoVO> getCarVoByNbNsAndReleaseTime(
			@Param("startDate") Date startDate, @Param("endDate") Date endDate)
			throws SQLException;

	/**
	 * 
	 * TODO:UNDONE,2013-11-20。
	 * 
	 * <pre>
	 * update autoinfosource set sbrand = {sbrand} , sseries = {sseries}
	 * where 1 = 1 
	 * and [ title is null or title = {title} ]
	 * and [ carName is null or carName = {carName} ]
	 * and sbrand is null 
	 * and sseries is null 
	 * [ and brand = {brand} or brand is null ]
	 * [ and series = {series} or series is null ]
	 * and releasetime between {startDate} and {endDate}
	 * </pre>
	 * 
	 * @param sb
	 * @param ss
	 * @param nb
	 * @param ns
	 * @param title
	 * @param carName
	 * @param startDate
	 *            精确到秒
	 * @param endDate
	 *            精确到秒
	 * @return
	 * @throws SQLException
	 */
	int updateSbSsByNbNsTC(@Param("sb") String sb,
			@Param("ss") String ss, @Param("nb") String nb,
			@Param("ns") String ns, @Param("title") String title,
			@Param("carName") String carName,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate)
			throws SQLException;

	int updateSbSsErrStepByNbNsTC(@Param("sb") String sb, @Param("ss") String ss,
			@Param("nb") String nb, @Param("ns") String ns,
			@Param("title") String title, @Param("carName") String carName,
			@Param("startDate") Date startDate, @Param("endDate") Date endDate,
			@Param("std_err_steps") String std_err_steps) throws SQLException;

}
